package com.xx.redBook.controller;

import com.xx.common.core.controller.BaseController;
import com.xx.common.core.domain.AjaxResult;
import com.xx.common.core.page.TableDataInfo;
import com.xx.redBook.domain.RedBookLike;
import com.xx.redBook.domain.vo.RedBookBatchLikeVO;
import com.xx.redBook.service.IRedBookLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 点赞下单Controller
 *
 * @author ruoyi
 * @date 2024-09-28
 */
@RestController
@RequestMapping("/redBook/like")
public class RedBookLikeController extends BaseController
{
    @Autowired
    private IRedBookLikeService redBookLikeService;

    /**
     * 查询bili点赞下单列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RedBookLike redBookLike)
    {
        startPage();
        List<RedBookLike> list = redBookLikeService.selectRedBookLikeList(redBookLike);
        return getDataTable(list);
    }

    /**
     * 根据oid，rpid，操作类型获取数量
     */
    @GetMapping("/checkOidRpidLikeCount")
    public AjaxResult checkOidRpidLikeCount(RedBookLike redBookLike)
    {
        return success(redBookLikeService.checkOidRpidLikeCount(redBookLike));
    }

    /**
     * 获取点赞下单
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(redBookLikeService.selectRedBookLikeById(id));
    }

    /**
     * 根据main链接获取评价列表
     */
    @GetMapping(value = "/getReplyByMainUrl")
    public AjaxResult getReplyByMainUrl(String url)
    {
        return success(redBookLikeService.getReplyByMainUrl(url));
    }


    /**
     * 新增点赞下单
     */
    @PostMapping
    public AjaxResult add(@RequestBody RedBookLike redBookLike)
    {
        return success(redBookLikeService.insertRedBookLike(redBookLike));
    }

    @PostMapping("batchRedBookLike")
    public AjaxResult batchRedBookLike(@RequestBody RedBookBatchLikeVO redBookBatchLikeVO)
    {
        redBookLikeService.batchRedBookLike(redBookBatchLikeVO);
        return success();
    }

    /**
     * 删除点赞下单
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(redBookLikeService.deleteRedBookLikeByIds(ids));
    }
}
